home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form3
- BorderStyle = 4 'Fixed ToolWindow
- Caption = "Disable the X with a click of a command button"
- ClientHeight = 1380
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 4635
- LinkTopic = "Form3"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 1380
- ScaleWidth = 4635
- ShowInTaskbar = 0 'False
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton Command2
- Caption = "E&xit"
- Height = 615
- Left = 0
- TabIndex = 1
- Top = 720
- Width = 4695
- End
- Begin VB.CommandButton Command1
- Caption = "Disable The X"
- Height = 735
- Left = 0
- TabIndex = 0
- Top = 0
- Width = 4695
- End
- Attribute VB_Name = "Form3"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub Command1_Click()
- Dim hSysMenu As Long
- Dim nCnt As Long
- ' First, show the form
- ' Get handle to our form's system menu
- ' (Restore, Maximize, Move, close etc.)
- hSysMenu = GetSystemMenu(Me.hwnd, False)
- If hSysMenu Then
- ' Get System menu's menu count
- nCnt = GetMenuItemCount(hSysMenu)
- If nCnt Then
- ' Menu count is based on 0 (0, 1, 2, 3...)
- RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
- RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE
- ' Remove the seperator
- DrawMenuBar Me.hwnd
- ' Force caption bar's refresh. Disabling X button
- Me.Caption = "Omg...The Caption Changed too"
- End If
- End If
- End Sub
- Private Sub Command2_Click()
- End Sub
-